#ifndef __FONTS__
#define __FONTS__

class BlockRenderers;
class ITexture;
#include <cstdint>
#include <cstring>
#include <memory>

#include "..\Math\Point2.h"

#ifndef byte
typedef unsigned char byte;
#endif

struct GlyphSize
{
public:
	byte Start, End;

	inline byte GetStartCol() { return Start; }
	inline byte GetEndCol() { return End; }
	inline byte GetWidth() { return GetEndCol() - GetStartCol() + 1; }

	inline void SetValues(const byte &start, const byte &end)
	{
		Start = start;
		End = end;
	}

	inline void SetValues(const byte &val)
	{
		Start = val >> 4;
		End = val & 0xF;
	}
};

class Fonts
{
	BlockRenderers *_renderers;
	GlyphSize _glyphSizes[UINT16_MAX];
	GlyphSize _defaultSizes[256];
	ITexture *_default;
	ITexture *_glyphs[256];
	bool _createdTextures;

public:
	Fonts(BlockRenderers *renderers) :
		_renderers(renderers),
		_createdTextures(false)
	{
	}

	void LoadGlyphSizes(const std::shared_ptr<byte> &data);
	void LoadGlyphs();

	std::pair<std::pair<Point2i, GlyphSize>, ITexture*> GetDataForChar(const wxChar16 &c, const bool &allGlyphs = true);
};

#endif